Using the ContentBlock Server Control Programmatically

The following code will display a content block:

Note: Before adding these lines of code, drag and drop a literal box on your Web form.

Dim MyContentBlock As New ContentBlock

MyContentBlock.DefaultContentID = 8

MyContentBlock.Page = Page

MyContentBlock.Fill()

Literal1.Text = MyContentBlock.EkItem.Html

To display a content block with the content block title, do the following:

Note: Before adding these lines of code, drag and drop a two literal boxes on your Web form.

Dim MyContentBlock As New ContentBlock

MyContentBlock.DefaultContentID = 8

MyContentBlock.Page = Page

MyContentBlock.Fill()

Literal1.Text = MyContentBlock.EkItem.Title

Literal2.Text = MyContentBlock.EkItem.Html

Previous TopicNext Topic|